<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div id="app">
        <h1>num:{{num}}</h1>
        <cc :num="num" @inc="increment" @dec="decrement"></cc>
    </div>

    <script src="../node_modules/vue/dist/vue.js"></script>
    <script type="text/javascript">
        let cc = {
            template: '\
            <div>\
                <button @click="plus">加</button>  \
                <button @click="reduce">减</button>  \
            </div>',
            methods: {
                plus(){
                    this.$emit("inc")
                },
                reduce(){
                    this.$emit("dec")
                }
            },
            props:['num']
        };


        let aa = new Vue({
            el: "#app",
            data: {
                num: 0
            },
            components: {
                cc
            },
            methods:{
                increment(){
                    this.num++;
                },
                decrement(){
                    this.num--;
                }
            }
        });
</script>
</body>
</html>